package com.contain.system.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Auther: tianchao
 * @Date: 2021/7/4 22:51
 * @Description:
 */
@RestController
@Slf4j
public class ClientController {

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/get")
    public String get(@RequestHeader(value = "username",required = false) String username){
        log.info("调用的人：{}",username);
        //String forObject = restTemplate.getForObject("http://contain-gateway/getUser", String.class);
        log.info("调用目标方法get..............");
        return "test";
    }
    @GetMapping("/getRrror")
    public String getRrror(@RequestHeader(value = "username",required = false) String username){
        if (true){
            throw new RuntimeException("出错了");
        }
        return "error";
    }
    @GetMapping("/ignore")
    public String insert(@RequestHeader(value = "username",required = false) String username){

        return "ignore";
    }
}
